<?php
namespace App\Http\Controllers\Admin;

// use Crypt;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Service\LoginService;

class LoginController extends CommentController
{
	private $_login;

	public function __construct()
	{
		$this->_login = LoginService::getInstance();
	}

	public function index(Request $request)
	{
		$fid = intval($request->cookie('fid'));
		if (session('fyback_info') != null) {
			return redirect()->action('Admin\IndexController@index');
		} elseif ($fid>0) {
			if ($this->_login->getFYBackData($request, $fid)['code'] == 200) {
				return redirect()->action('Admin\IndexController@index');
			}
		}
		// var_dump(Crypt::encrypt('123456'));
		return view('admin.login');
	}

	public function log(Request $request)
	{
		$data = $request->all();
		
		$list = $this->_login->adminLogin($request, $data);
		return json_encode($list);
	}
}